"""
ASGI config for helloDjangoPython project.

It exposes the ASGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/
"""

from django.http import JsonResponse
from django.http import HttpResponse 
import urllib.request, urllib.error 
 
def readurl(request):
    try:
        rsp = urllib.request.urlopen(request.GET["url"])
        return HttpResponse(rsp.read().decode("UTF-8"))
    except urllib.error.HTTPError as e:
        # Return code error (e.g. 404, 501, ...)
        return HttpResponse(e.code)


def menu(request):
    return JsonResponse({'code': 20000, })